bb()
Prgm
ClrDraw
Local message,unpack,del,progset

Define message(ms)=Prgm
 Local msl,kk
 119-round(dim(ms)*6/2,0)->msl
 NewPic [[102,238]],kk,17,dim(ms)*6+10
 RplcPic kk,45,msl-5
 PxlLine 45,msl-5,45,msl+dim(ms)*6+5
 PxlLine 62,msl-5,62,msl+dim(ms)*6+5
 PxlLine 45,msl-5,62,msl-5
 PxlLine 45,msl+dim(ms)*6+5,62,msl+dim(ms)*6+5
 PxlText ms,50,msl
 Pause 
 RplcPic kk,45,msl-5
EndPrgm


unpack images

Define unpack(iiimg)=Prgm
 Local bgg
 StoPic bgg,0,0,54,16
 RplcPic #iiimg
 StoPic man1,0,0,8,17
 StoPic man2,0,8,8,16
 StoPic block1,0,16,8,8
 StoPic block2,0,24,8,8
 StoPic escp,0,32,8,8
 StoPic enegy,8,16,6,6
 StoPic block3,8,22,8,8
 StoPic ufo,8,30,17,8
 StoPic livepic,0,40,4,9
 StoPic lava,0,44,8,8
 RplcPic bgg
EndPrgm

Define del()=Prgm
 DelVar man1
 DelVar man2
 DelVar block1
 DelVar block2
 DelVar block3
 DelVar escp
 DelVar enegy
 DelVar ufo
 DelVar energy
 DelVar livepic
 DelVar lava
EndPrgm

Define progset(dir)=Prgm
 If dir=1 and energy<16 Then
  PxlLine energy*4+10,233,energy*4+10,236,1
  PxlLine energy*4+11,233,energy*4+11,236,1

ElseIf dir=2 and energy<16 Then
  PxlLine (energy+1)*4+10,233,(energy+1)*4+10,236,1
  PxlLine (energy+1)*4+11,233,(energy+1)*4+11,236,1
EndIf
EndPrgm

unpack("img")


freakware logo
If getType(freakw)"NONE" Then
  freakw()
EndIf

ClrDraw
ClrIO

Local men,menn,ef,blk

axes off, coordinates off, ect
 setGraph("coordinates","off")
 setGraph("axes","off")
 setMode("Exact/Approx","EXACT")

Title menu
For menn,0,50,50
 For men,19,67,8
  "block"&string(rand(3))->blk
  RclPic #blk,men,67+menn
EndFor
For men,19,75,24
  "block"&string(rand(3))->blk
  RclPic #blk,men,75+menn
EndFor
For men,19,75,24
  "block"&string(rand(3))->blk
  RclPic #blk,men,83+menn
EndFor
For men,19,75,24
  "block"&string(rand(3))->blk
  RclPic #blk,men,91+menn
EndFor
  "block"&string(rand(3))->blk
  RclPic #blk,27,99+menn
  RclPic #blk,35,99+menn
  RclPic #blk,51,99+menn
  RclPic #blk,59,99+menn

EndFor

Pause 

cool effect
For ef,1,102,2
 PxlHorz ef,1
 PxlHorz 102-ef,1
EndFor

ClrDraw

choose levels-load level
Local level,levels,xxx,yyy,yy,xx,strtimg,levn,tp,names,levvv,tpp

If getType(strlev)"LIST" Then
newList(1)->strlev
EndIf

Lbl lrv

newList(0)->levels

For levn,1,10
 "world"&string(levn)->tp
 If getType(#tp)="MAT" Then
  augment(levels,{tp})->levels
  SortA levels
 EndIf
EndFor


 newList(0)->names
 dim(levels)->levvv
 For levn,1,levvv
  levels[levn]->tp
  #tp[1,30]->tp
  augment(names,{tp})->names
 EndFor

0->levn
Try
 Dialog
  Title "Choose level"
  DropDown "Level:",names,levn
  Text "Press esc to quit"
 EndDlog
Else
 Text "NO LEVELS FOUND"
 DispHome
 del()
 Stop
EndTry

If levn=0 Then
 DispHome
 del()
 Stop
EndIf

Try
 expr(levels[levn])->level
Else
 Goto lrv
EndTry

Local lives,y,x,tmpppic,cntt,energy2

 2->lives
 RclPic livepic,92,233
 RclPic livepic,82,233
 PxlLine 3,0,3,238
 PxlLine 102,1,102,238
 PxlLine 3,231,102,231
 PxlLine 3,238,102,238
 PxlLine 80,232,80,238
 RclPic enegy,7,232



Lbl ldlev

 StoPic tmpppic,14,232,6,65
 XorPic tmpppic,14,232


 levels[levn]->tp
 #tp[2,30]-1->energy
 energy->energy2

For tp,1,energy+1
  If tp=16:Exit
  PxlLine tp*4+10,233,tp*4+10,236,1
  PxlLine tp*4+11,233,tp*4+11,236,1
EndFor

 level[3,30]->tpp
 If getType(#tpp)="PIC":unpack(tpp)


Load Level:



If strlev[1]levels[levn] Then
 For yyy,1,12
  For xxx,1,29
   level[yyy,xxx]->tp
    If tp=1 Then
     RclPic block1,yyy*8-2,xxx*8-8
   
    ElseIf tp=2 Then
     RclPic block2,yyy*8-2,xxx*8-8
   
    ElseIf tp=3 Then
       For xx,0,7
        PxlOn yyy*8-2+8-rand(8),xx+xxx*8-8
      EndFor

     RclPic lava,yyy*8-2,xxx*8-8
   
    ElseIf tp=4 Then
     yyy*8-10->y
     xxx*8-8->x

    ElseIf tp=5 Then
      RclPic block3,yyy*8-2,xxx*8-8

    ElseIf tp=6 Then
     RclPic escp,yyy*8-2,xxx*8-8
    EndIf
  EndFor
 EndFor

 StoPic strtpic,0,0,232,102
 StoPic strtimg,0,0,232,102

 newList(3)->strlev

 levels[levn]->strlev[1]
 y->strlev[2]
 x->strlev[3]
 RclPic man1,y,x
Else
 RplcPic strtpic
 StoPic strtimg,0,0,232,102
 strlev[2]->y
 strlev[3]->x
 RclPic man1,y,x
 expr(levels[levn])->level
EndIf

Local key,key_up,key_down,key_left,key_rht,key_f1,man,height,p

13->height
338->key_up
344->key_down
337->key_left
340->key_rht
268->key_f1
0->key
1->p

here the fun starts...

Lbl loop1      start loop
 
getKey()->key

   PxlText string(energy),14,232

If energy>energy2 Then
  progset(1)
  energy->energy2
ElseIf energy<energy2 Then
  progset(2)
  energy->energy2
EndIf

fall down
If y+8=94 Then nothing 
  ElseIf level[round(y/8,0)+2,x/8+1]=0 or level[round(y/8,0)+2,x/8+1]=3 or level[round(y/8,0)+2,x/8+1]=6 Then
    RplcPic strtimg
    y+8->y
    "man"&string(p)->man
    RclPic #man,y,x
    Goto points
EndIf

go left

If key=key_left Then
  1->p
  If x>0 Then:If level[round(y/8,0)+1,x/8]=0 or level[round(y/8,0)+1,x/8]=3 or level[round(y/8,0)+1,x/8]=6:x-8->x:EndIf
  RplcPic strtimg
  RclPic man1,y,x
  Goto points
go right

ElseIf key=key_rht Then
 2->p
If x<222 Then:If level[round(y/8,0)+1,x/8+2]=0 or level[round(y/8,0)+1,x/8+2]=3 or level[round(y/8,0)+1,x/8+2]=6:x+8->x:EndIf
 RplcPic strtimg
 RclPic man2,y,x
 Goto points
EndIf

check height

If round(y/8,0)+1<height Then
  round(y/8,0)+1->height
  energy+1->energy

go up
ElseIf key=key_up and x>0 Then
 If p=1 and level[round(y/8,0)+1,x/8]0 and level[round(y/8,0),x/8+1]=0 Then: 
  If level[round(y/8,0),x/8]=0 or level[round(y/8,0),x/8]=6 or level[round(y/8,0),x/8]=3 Then
       RplcPic strtimg
        x-8->x
        y-8->y
       RclPic man1,y,x
  EndIf

 ElseIf p=2 and level[round(y/8,0)+1,x/8+2]0 and level[round(y/8,0),x/8+1]=0 Then
 
  If level[round(y/8,0),x/8+2]=0 or level[round(y/8,0),x/8+2]=6 or level[round(y/8,0),x/8+2]=3 Then
      RplcPic strtimg
       x+8->x
       y-8->y
      RclPic man2,y,x
  EndIf
 EndIf


shoot block
ElseIf key=key_f1 Then
 If p=1 and x>0 Then

   If level[round(y/8,0)+1,x/8]=1 or level[round(y/8,0)+1,x/8]=5 Then

   If level[round(y/8,0)+1,x/8]=5 Then
    energy+1->energy
    XorPic block3,y+8,x-8
   Else
    energy-1->energy
    XorPic block1,y+8,x-8
   EndIf

   0->level[round(y/8,0)+1,x/8]
   round(y/8,0)+1->cntt

   While cntt-11 and level[cntt-1,x/8]0
     level[cntt-1,x/8]->level[cntt,x/8]
     0->level[cntt-1,x/8]
     cntt-1->cntt
   EndWhile

   If cntt<round(y/8,0)+1 Then
     StoPic tmpppic,cntt*8-2,x-8,8,(round(y/8,0)+1-cntt)*8
     XorPic tmpppic,cntt*8-2,x-8
     RclPic tmpppic,cntt*8+6,x-8
   EndIf

   XorPic man1,y,x
   StoPic strtimg,0,0,232,102
   RclPic man1,y,x
   PxlLine 3,231,102,231
   Goto points
  EndIf
EndIf

  If p=2 Then
   If level[round(y/8,0)+1,x/8+2]=1 or level[round(y/8,0)+1,x/8+2]=5 Then
   If level[round(y/8,0)+1,x/8+2]=5 Then
    energy+1->energy
    XorPic block3,y+8,x+8
   Else
    energy-1->energy
    XorPic block1,y+8,x+8
   EndIf

   0->level[round(y/8,0)+1,x/8+2]
   round(y/8,0)+1->cntt
 
   While cntt-11 and level[cntt-1,x/8+2]0
      level[cntt-1,x/8+2]->level[cntt,x/8+2]
     0->level[cntt-1,x/8+2]
     cntt-1->cntt

   EndWhile

   If cntt<round(y/8,0)+1 Then
    StoPic tmpppic,cntt*8-2,x+8,8,(round(y/8,0)+1-cntt)*8
    XorPic tmpppic,cntt*8-2,x+8
    RclPic tmpppic,cntt*8+6,x+8
   EndIf
   
   XorPic man2,y,x
   StoPic strtimg,0,0,232,102
   RclPic man2,y,x
   PxlLine 3,231,102,231
   Goto points
  EndIf
EndIf
EndIf


points-lives,ect
Lbl points
If level[round(y/8,0)+1,x/8+1]=3 or energy=0 Then
 If lives=0 Then
   message("Game Over")
   ClrDraw
   Goto lrv
 Else
   lives-1->lives
   XorPic livepic,92-lives*10,233
   message("YOU ARE DEAD")
   Goto ldlev
 EndIf

ElseIf level[round(y/8,0)+1,x/8+1]=6 Then
   "man"&string(p)->tp
   RplcPic #tp,y,x
   Goto win
 ElseIf key=63 Then
  ClrDraw
  Goto lrv
EndIf

Goto loop1     endloop

Lbl win
  
214->xx
  6->yy
 
  StoPic tmpppic,yy,x-8,238-x,8
  XorPic tmpppic,yy,x-8
  For tp,1,200:EndFor
  RplcPic ufo,yy,xx

While xxx-3
  For tp,1,2:EndFor
  xx-1->xx
  RplcPic ufo,yy,xx
EndWhile

For tp,1,300:EndFor

StoPic tmpppic,14,x,8,92-(102-y)
XorPic tmpppic,14,x

For tp,1,100:EndFor

While yyy
 y-1->y
 RplcPic man1,y+8,x
EndWhile

XorPic man1,y+8,x

For tp,1,300:EndFor

NewPic [[102,238]],tmpppic,7,1

While xx214
  For tp,1,2:EndFor
  xx+1->xx
  RplcPic ufo,yy,xx
  RplcPic tmpppic,yy,xx-1
EndWhile
  XorPic ufo,yy,xx
  RplcPic tmpppic,yy,xx-1
 
 For tp,1,300:EndFor

 cool effect
 For ef,1,102,2
  PxlHorz ef,1
  PxlHorz 102-ef,1
 EndFor


 message("YoU hAVe wON!!!!!!")
 For tp,1,100:EndFor
 message("Thank you for playing this Game")
 ClrDraw
 DelVar energy
 Goto lrv
EndPrgm